<?php
include  'admin/loginCheck.php';
include  'admin/Util.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
    <head>
        <?php
        include  'meta.php';
        ?>
        <title><?php echo Constants::$mainHeader ?></title>
        <?php
        include  'headIcon.php';
        ?>
        <link rel="stylesheet" type="text/css" href="media/default.css" media="screen" />
        <link rel="stylesheet" type="text/css" href="lightbox/lightbox.css" media="screen" />
        <script type="text/javascript" src="lightbox/prototype.js"></script>
        <script type="text/javascript" src="lightbox/scriptaculous.js?load=effects"></script>
        <script type="text/javascript" src="lightbox/lightbox.js"></script>
        <!-- TODO: doplnit meta copyright, description, keywords -->
    </head>
    <body>

        <h1>Fibix Studio &ndash; Interactive 3D Visuals</h1>


        <?php
        include  'menu.php';
        ?>

        <!-- CONTENTS START -->

        <div id="contents">
            <div class="boxtop"></div>
            <div class="boxhdr"><h2>What is Fibix</h2></div>
            <div class="boxtxt">
                <div id="boxvid">placeholder for flash video<br />711x350 pix</div>
            </div>
            <div class="boxhdr"><h2>News</h2></div>
            <div class="boxtxt">

                <?php

                $link = Util::getLink();

                $query = sprintf(Util::$select_jornakDestinationAllById,
                    mysql_real_escape_string($_GET['newDestId'])
                );

                $result = mysql_query($query);

                if (!$result) {
                    die('Could not query:' . mysql_error());
                }

                $i = 1;
                $row = mysql_fetch_assoc($result);
                $textID[$i] = $row['textid'];
                $time[$i] = $row['time'];

                $query = sprintf(Util::$select_jornakDestination,
                    mysql_real_escape_string("1")
                );

                $result = mysql_query($query);

                if (!$result) {
                    die('Could not query:' . mysql_error());
                }

                while ($row = mysql_fetch_assoc($result)) {
                    $i++;
                    if ($i == 4) break;
                    $textID[$i] = $row['textid'];
                    $time[$i] = $row['time'];
                }

                for ($i = 1; $i < 4; $i++) {
                    if ($i == 1) $saveID = $textID[$i];
                    if ($textID[$i] == null) break;
                    $query = sprintf(Util::$select_jornakText,
                        mysql_real_escape_string($textID[$i])
                    );

                    $result = mysql_query($query);

                    if (!$result) {
                        die('Could not query:' . mysql_error());
                    }

                    while ($row = mysql_fetch_assoc($result)) {
                        echo "<h3>".stripslashes($row['header'])."</h3>";
                        echo '<p class="date">'.Util::parseDateTime($time[$i])."</p>";
                        echo "<p>".stripslashes($row['text'])."</p>";
                        if ($i < 3) echo "<hr />";
                    }
                }

                Util::closeLink($link);

                ?>

                <div id="cleaner"></div>
            </div>
            <div class="boxbtm"></div>
        </div>

        <!-- CONTENTS END -->

        <div id="footer">
            <p><a href="career.html">CAREER</a> | <a href="contacts.html">CONTACT US</a> | Copyright &copy; 2011 Fibix Studio. All rights reserved. Created by <a href="http://biganovsky.com" onclick="target='_blank'">TakJakDesign</a>.</p>
            <form method="post" action="admin/adminResolveNews.php">
                <p>
                    <?php
                    if (isset($_GET['new'])) {
                        if ($_GET['new'] == 1) {?>
                    <input type="hidden" name="finalNew" value="true" />
                        <?php }else {?>
                    <input type="hidden" name="finalEdit" value="true" />
                    <input type="hidden" name="oldTextId" value="<?php echo $_GET['oldTextId'] ?>" />
                        <?php } }?>

                    <input type="hidden" name="final" value="<?php echo $_GET['newDestId'] ?>" />
                    <input id="saveForm" class="button_text" type="submit" name="submit" value="Back" />
                    <input id="saveForm" class="button_text" type="submit" name="submit" value="Ok" />
                </p>
            </form>
        </div>        
    </body>
</html>